let _flag = true
export default {
  data() {
    return {
      isVrMode: false,
      clickVr: true,
      vrFlag: true,
    }
  },
  mounted() {
    this.$vgo.on('vr:show', flag => {
      console.log('1---2555-------')
      this.isVrMode = true
      this.vrFlag = flag
      this.toggleCtrlBar()
      // 监听触摸事件 显示 CtrlBar
      if (_flag) {
        _flag = false
        document.querySelector('#app').addEventListener('touchstart', this.showCtrlBar, true)
      }
    })
    this.$vgo.on('vr:hide', flag => {
      this.vrFlag = flag
      this.isVrMode = false
      document.querySelector('#app').removeEventListener('touchstart', this.showCtrlBar, true)
      _flag = true
    })
    this.$vgo.on('vr:click', () => {
      this.clickvr = true
    })
  },
  methods: {
    showCtrlBar() {
      this.clickVr = true
      this.toggleCtrlBar()
    },
    // 5秒钟隐藏
    toggleCtrlBar() {
      this.$_timer && clearTimeout(this.$_timer)
      this.$_timer = setTimeout(() => {
        this.clickVr = false
        this.$_timer = null
      }, 5000)
    },
  },
}
